Skip to content

feat(markdown): cite selected file text in chat - #282

Merged
yaacovcorcos merged 5 commits into
mainfrom
codex/markdown-file-citations-20260910
Sep 11, 2026
Merged

feat(markdown): cite selected file text in chat#282
yaacovcorcos merged 5 commits into
mainfrom
codex/markdown-file-citations-20260910

Conversation

@yaacovcorcos

Copy link
Copy Markdown
Contributor

Problem

The chat's Cite action cannot currently capture selected text from a rendered workspace Markdown file. A plain file reference does not retain the selected passage or distinguish an unsaved draft from the file on disk.

Behavior and architecture

  • Add Cite to rendered workspace Markdown text, including paragraphs, lists, table cells, and partial ordinary code-block selections.
  • Reuse the existing selection toolbar, atomic composer quote/comment node, clipboard and draft serialization, sent-message chip, and shared provider-send boundary. Assistant quote links keep their existing format and behavior.
  • Capture selected text, original environment/workspace/path, containing source block/line range, and saved/draft snapshot provenance from the current editor session. No document reparse, save, undo mutation, new database, or provider-specific implementation is added.
  • Reopen the original source through the existing route and pending-save policy. Only verified source ranges are highlighted; changed/ambiguous text retains its saved quote and gets an explanatory warning. A thread moved to another worktree opens its original file read-only instead of targeting the new worktree.
  • Keep the rich editor lazily loaded. Native mobile retains a readable quote/context fallback.

This first pass does not add PDF/HTML selection, whole-image/math/chart capture, source-mode capture, or a general annotation framework. Source lines enclose the selection; they are not claimed to be exact Markdown character offsets.

Verification

Automated qualification and manual acceptance are separate. Native visual review is pending with the owner; no computer-use or browser automation was performed, per request.

Focused coverage includes mounted ProseMirror/CodeMirror selection, the real composer and comment popover, serialization/paste/reload/removal, sanitized sent-message rendering, route identity and pending-save deferral, Strict Mode highlight cleanup, and the common provider boundary with mocked adapters. Stress cases include 250 repeated edit/capture cycles, 5,000 repeated paragraphs, Unicode/CRLF, malformed payloads, and 20,000 unfinished links. Tests also reject selections crossing a rendered chart's hidden source.

Passed:

  • Full monorepo test suite: 19,988 passed, with the repository's existing platform/optional skips. The final frontend rerun after the additional Strict Mode regression test passed all 6,996 tests; server suite: 6,258 passed.
  • Full monorepo typecheck, plus the final affected frontend typecheck.
  • Full production build, plus the final frontend rebuild; Markdown remains a dynamic entry in the emitted manifest.
  • Desktop smoke test, formatting check, lint (existing repository warnings, no errors), and git diff --check.
  • Analysis, onboarding, Skills, and LaTeX seam checks against the recorded upstream integration point 6c583620ff7ad3235b135af7107c0543467eecfa, and upstream provenance verification.

Before delivery, the unpublished branch was checked against fresh origin/main at 7cefb603ef43fe0c4555826ceeb67b0e2338c668 and had no intervening main commits to integrate. Initial qualification exposed an Electron auto-install race in the fresh dependency tree; explicitly completing the local Electron install resolved it without product changes. A loaded parallel run also exceeded the existing editor performance threshold; the clean full-suite and final frontend reruns passed without weakening any threshold.

Documentation impact

Updated — docs/user/composer.md, docs/internals/scient-rich-markdown-editor.md, and UPSTREAM.md document the workflow, narrow architecture, and deliberate shared-entry-point extension.

Agent disclosure

Implemented and reviewed with OpenAI Codex in the Codex desktop agent harness. The exact model identifier is not exposed in this session. Provider tests use mocks; real-provider interaction and visual acceptance are left to the owner's isolated dev-app review.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:XXL labels Sep 10, 2026
@github-actions

github-actions Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

ℹ️ The exact PR base did not have a successful artifact. Baseline uses the latest successful main measurement shown below.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 13.5 KiB 13.6 KiB +127 B (+0.9%) 15.1 KiB
Codex Thread snapshot wire 7.1 KiB 7.1 KiB +1 B (+0.0%) 7.3 KiB
Codex Live turn WebSocket wire 6.4 KiB 6.5 KiB +126 B (+1.9%) 7.8 KiB
Codex Live turn WebSocket decoded 56.2 KiB 57.0 KiB +866 B (+1.5%) 66.4 KiB
Codex Live turn messages 8 9 +1 (+12.5%) 21
Claude Total thread wire 13.6 KiB 13.6 KiB +21 B (+0.2%) 15.1 KiB
Claude Thread snapshot wire 7.1 KiB 7.1 KiB −4 B (−0.1%) 7.3 KiB
Claude Live turn WebSocket wire 6.5 KiB 6.5 KiB +25 B (+0.4%) 7.8 KiB
Claude Live turn WebSocket decoded 57.8 KiB 57.8 KiB +44 B (+0.1%) 66.4 KiB
Claude Live turn messages 8 9 +1 (+12.5%) 21

Baseline: 7937489 · PR result: b21b966 · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 114.1 KiB
  • Claude decoded thread snapshot: 114.7 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@yaacovcorcos
yaacovcorcos marked this pull request as ready for review September 11, 2026 04:29
@yaacovcorcos
yaacovcorcos enabled auto-merge (squash) September 11, 2026 04:29
@yaacovcorcos
yaacovcorcos force-pushed the codex/markdown-file-citations-20260910 branch from 88383e1 to b21b966 Compare September 11, 2026 04:51
@yaacovcorcos
yaacovcorcos merged commit 3704541 into main Sep 11, 2026
24 checks passed
@yaacovcorcos
yaacovcorcos deleted the codex/markdown-file-citations-20260910 branch September 11, 2026 04:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant